package com.woniu.order.controller;

import com.woniu.common.utils.ResponseData;
import com.woniu.order.dto.ApplyOrderDto;
import com.woniu.order.service.ZfTraderorderaService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program: ECP
 * @description:
 * @create: 2024-11-23 15:26
 **/
@RestController
@RequestMapping("/zf")
@Slf4j
public class ZfApplyController {
    @Autowired
    private ZfTraderorderaService zfTraderorderaService;

    /**
     * 申请分销商订单
     */
    @PostMapping("/applyOrder")
    public ResponseData<?> applyOrder(@RequestBody ApplyOrderDto applyOrderDto){
        log.info(applyOrderDto.getProductList().toString());
        return zfTraderorderaService.applyOrder(applyOrderDto);
    }

    /**
     * 全部的分销商
     */
    @PostMapping("/queryAllByTrader")
    public ResponseData<?> queryAllByTrader(){
        return zfTraderorderaService.queryAllByTrader();
    }

    /**
     * 根据code查分销商
     */
    @PostMapping("/queryByTraderCode")
    public ResponseData<?> queryByTraderCode(@RequestParam("code") String code){
        return zfTraderorderaService.queryByTraderCode(code);
    }

    /**
     * 查全部生产商品
     */
    @PostMapping("/queryAllByProduct")
    public ResponseData<?> queryAllByProduct(){
        return zfTraderorderaService.queryAllByProduct();
    }

    /**
     * 查具体的生产商品
     */
    @PostMapping("/queryByProductCode")
    public ResponseData<?> queryByProductCode(@RequestParam("id") String code){
        return zfTraderorderaService.queryByProductCode(code);
    }
}